<!DOCTYPE html>
<html>
	<head>
		<title>计算器</title>
		<meta charset="UTF-8" />
		<meta http-equiv="Content-Type" content="text/html"/>
		<script type="text/javascript">
			window.onload=function(){
				document.getElementById("text1").focus();
			};
			function set(sign){
				document.form.expression.value+=sign;
				//document.getElementById("text1").value+=sign;
			}
			function cal(){
				document.form.result.value=eval(document.form.expression.value);
			}
			function clearText(){
				document.form.expression.value="";
				document.form.result.value="";
			}
			function backspace(){
				var str=document.form.expression.value;
				var len=str.length;
				document.form.expression.value=str.substring(0,len-1);
			}
			function keyLogin(){
				if(event.keyCode==13){
					//cal();
					document.getElementById("input1").click();
				}
			}
		</script>
		<style type="text/css">
			input.box{
				width:400px;
				height: 40px;
				align:right;
			}
			input{
				width:100px;
				height: 50px;
				align:center;
				font-size: 30px;
				/*font-weight: 700;*/
				color: black;
			}
			div{
				/*position:fixed;
				left:400px;*/
				text-align: center;
			}
			body{
				background:url(bg.jpg) repeat-x;
			}
		</style>
	</head>
	<body onkeydown="keyLogin()">
		<div>
			<form action="" method="post" name="form">
				<p><font size="100px" color="blue">普通计算器</font></p>
				<p>
				<input type="text" name="expression" id="text1" value="" class="box"/>
				</p>
				<p>
				<input type="text" name="result" id="text2" value="" class="box"/>
				</p>
				<p>
					<input type="button" name="" id="" value="CE" onclick="clearText()"/>
					<input type="button" name="" id="" value="C" onclick="clearText()"/>
					<input type="button" name="" id="" value="B" onclick="backspace()"/>
					<input type="button" name="" id="" value="/" onclick="set('/')"/>
				</p>
				<p>
					<input type="button" name="" id="" value="7" onclick="set(7)" />
					<input type="button" name="" id="" value="8" onclick="set(8)" />
					<input type="button" name="" id="" value="9" onclick="set(9)"/>
					<input type="button" name="" id="" value="*" onclick="set('*')"/>
				</p>
				<p>
					<input type="button" name="" id="" value="4" onclick="set(4)"/>
					<input type="button" name="" id="" value="5" onclick="set(5)"/>
					<input type="button" name="" id="" value="6" onclick="set(6)"/>
					<input type="button" name="" id="" value="-" onclick="set('-')"/>
				</p>
				<p>
					<input type="button" name="" id="" value="1" onclick="set(1)"/>
					<input type="button" name="" id="" value="2" onclick="set(2)"/>
					<input type="button" name="" id="" value="3" onclick="set(3)"/>
					<input type="button" name="" id="" value="+" onclick="set('+')"/>
				</p>
				<p>
					<input type="button" name="" id="" value="-+" />
					<input type="button" name="" id="" value="0" onclick="set(0)"/>
					<input type="button" name="" id="" value="." onclick="set('.')"/>
					<input type="button" name="" id="input1" value="=" onclick="cal()"/>
				</p>
			
			
			
			
			</form>
		</div>
	</body>
</html>